
from ddddocr import DdddOcr

# 从图片的 bytes 中获得文字内容
def textFromBytes(bytes,range=6):

    ocr1=DdddOcr()
    ocr1.set_ranges( range )
    res=ocr1.classification(bytes)
    return res

# 读取文件图片中的文字
def textFromImgFile(imgfile, range=6):
    ocr1=DdddOcr()
    ocr1.set_ranges( range )

    with open(imgfile, 'rb') as f1:
        imgbytes = f1.read()

        res=ocr1.classification(imgbytes)
        return res

